package com.qf.controller;

import com.qf.pojo.User;
import com.qf.service.UserService;
import com.qf.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public BaseResult login(@RequestBody User user, HttpSession session){
        return userService.userLogin(user,session);
    }
    @RequestMapping(value = "/register",method = RequestMethod.POST)
    public BaseResult register(@RequestBody User user,HttpSession session){
        return userService.userRegister(user,session);
    }
    @RequestMapping(value = "/isLogin",method = RequestMethod.POST)
    public BaseResult isLogin(HttpSession session){
        return userService.isLogin(session);
    }

    @RequestMapping(value = "/updatetel",method = RequestMethod.POST)
    public BaseResult updateTel(@RequestParam("tel") String tel, HttpSession session){
        return userService.updateTel(tel, session);
    }

    @RequestMapping(value = "/updateemail",method = RequestMethod.POST)
    public BaseResult updateemial(@RequestParam("email") String email, HttpSession session){
        return userService.updateEmail(email,session);
    }

    @RequestMapping(value = "/updatepassword",method = RequestMethod.POST)
    public BaseResult updatePassword(@RequestParam("password") String password,
            @RequestParam("repassword") String repassword ,HttpSession session){
        return userService.updatePassword(password, repassword, session);
    }
}
